﻿using System;
using System.IO;
using System.Linq;

namespace Terraria.ModLoader.IO
{
	// Token: 0x020002BE RID: 702
	public class BigEndianWriter : BinaryWriter
	{
		// Token: 0x06001B91 RID: 7057 RVA: 0x00013D37 File Offset: 0x00011F37
		public BigEndianWriter(Stream output) : base(output)
		{
		}

		// Token: 0x06001B92 RID: 7058 RVA: 0x00013D40 File Offset: 0x00011F40
		private void WriteBigEndian(byte[] bytes)
		{
			if (BitConverter.IsLittleEndian)
			{
				bytes = bytes.Reverse<byte>().ToArray<byte>();
			}
			this.Write(bytes);
		}

		// Token: 0x06001B93 RID: 7059 RVA: 0x00013D5D File Offset: 0x00011F5D
		public override void Write(short value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B94 RID: 7060 RVA: 0x00013D6B File Offset: 0x00011F6B
		public override void Write(ushort value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B95 RID: 7061 RVA: 0x00013D79 File Offset: 0x00011F79
		public override void Write(int value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B96 RID: 7062 RVA: 0x00013D87 File Offset: 0x00011F87
		public override void Write(uint value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B97 RID: 7063 RVA: 0x00013D95 File Offset: 0x00011F95
		public override void Write(long value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B98 RID: 7064 RVA: 0x00013DA3 File Offset: 0x00011FA3
		public override void Write(ulong value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B99 RID: 7065 RVA: 0x00013DB1 File Offset: 0x00011FB1
		public override void Write(float value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}

		// Token: 0x06001B9A RID: 7066 RVA: 0x00013DBF File Offset: 0x00011FBF
		public override void Write(double value)
		{
			this.WriteBigEndian(BitConverter.GetBytes(value));
		}
	}
}
